﻿<?php
require_once( dirname(__FILE__).'/./libs/bedmintonlib.php' );

function auto_version( $file )
{
    if (! file_exists( $file ))
        return $file;

    $mtime = filemtime( $file );
    $outStr = $file . "?v=" . $mtime;
    return $outStr;
}

function appendStySheet( $fileName )
{
    return ( "<link rel=\"stylesheet\" href=\"" . auto_version( "./css/" . $fileName ) . "\" type=\"text/css\">" );  
}

function appendJavaScriptFile( $fileName )
{
    return ( "<script type=\"text/javascript\" src=\"" . auto_version( "./javascripts/" . $fileName ) . "\"></script>" );  
}

if (! isset( $_SESSION[ 'page_viewed' ] ))
{
    $_SESSION[ 'page_viewed' ] = 1;
    WebStat::logLoadMainSite();
}

$echoStr = " <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">
    <html><head>
    <meta http-equiv=\"content-type\" content=\"text/html;charset=UTF-8\">
    <meta name=\"description\" content=\"Prenájom a online rezervácia bedmintonových kurtov.\">
    <meta name=\"keywords\" content=\"bedminton,kurty,Vlčie hrdlo,online rezervácia\">
    <meta http-equiv=\"Pragma\" content=\"no-cache\" >
    <meta http-equiv=\"Cache-Control\" content=\"no-cache\" >
    <title>Bratislavské Bedmintonové Centrum</title>";

$echoStr .= appendJavaScriptFile( "jquery-1.7.js" );
$echoStr .= appendJavaScriptFile( "jquery.validate.js" );

$subSiteName = "mainsites/main.php";
if (isset( $_GET['siteName'] ))
{
    $subSiteName = $_GET['siteName'];
}

if ($subSiteName == "mainsites/pricelist.php")
{
    $echoStr .= appendStySheet( "pricelist.css" );
}
else if ($subSiteName == "mainsites/reservation.php")
{
    $echoStr .= appendStySheet( "reservation.css" );
}
else if ($subSiteName == "mainsites/gallery.php" || $subSiteName == "mainsites/gallerydetails.php")
{
    $echoStr .= appendStySheet( "gallery.css" );
    $echoStr .= appendStySheet( "jquery.fancybox.css" );
    $echoStr .= appendStySheet( "jquery.fancybox-buttons.css" );
    $echoStr .= appendJavaScriptFile( "jquery.mousewheel-3.0.6.pack.js" );
    $echoStr .= appendJavaScriptFile( "jquery.fancybox.pack.js" );
    $echoStr .= appendJavaScriptFile( "jquery.fancybox-buttons.js" );
}
else if ($subSiteName == "mainsites/main.php")
{
    $echoStr .= appendJavaScriptFile( "jqFancyTransitions.1.8.js" );
    $echoStr .= appendStySheet( "about_us.css" );
    $echoStr .= appendStySheet( "contacts.css" );
    $echoStr .= appendStySheet( "home.css" );
    $echoStr .= appendStySheet( "howtoregister.css" );
    $echoStr .= appendStySheet( "regulas.css" );      
}
   
$echoStr .= appendStySheet( "index.css" );
$echoStr .= appendStySheet( "main.css" );
$echoStr .= appendStySheet( "header.css" );
$echoStr .= appendStySheet( "footer.css" );
$echoStr .= appendStySheet( "forms.css" );
$echoStr .= "</head><body>";

if (isset( $_GET[ 'language' ] ))
{
    $_SESSION[ 'language' ] = $_GET[ 'language' ];
}

$echoStr .= "<div class=\"logo\"><img src=\"./images/logo.png\" alt=\"no logo\" /></div>";
$echoStr .= "<div class=\"mainSiteStyle\">";
echo( $echoStr );
   include 'mainsites/header.php'; 
   include 'mainsites/footer.php';
   
echo("<div class=\"subSiteStyle\">");
    include ( $subSiteName );
echo( "</div>" );
    
echo( "</div></body></html>");
?>